package model

type User struct {
	//`json:"username"` 相当于取别名
	Username string `json:"username"`
	Name     string `json:"name"`
	Age      int    `json:"age"`
	Sex      int    `json:"sex"`
	Address  string `json:"address" gorm:"colum:address"` //gorm:"colum:address"指定列名
}

type UserQuery struct {
	//form是做参数映射
	//binding是绑定的意思，required值意思为必有，没有就报错，类似于@NotEmpty
	Username string `json:"username" form:"username" binding:"required"`
	Name     string `json:"name" form:"name" binding:"required,nameCheck"`
}

type Users struct {
	UserList []User `json:"userList"`
	Size     int    `json:"size"`
}

type UserDetail struct {
	Username   string
	SchoolName string
}

type UserVO struct {
	User              // 匿名属性，可以使用User里面的属性
	SchoolName string `json:"schoolName" gorm:"column:school_name"`
}

type UserOne2Many struct {
	Username   string       `json:"username"`
	Name       string       `json:"name"`
	Age        int          `json:"age"`
	Sex        int          `json:"sex"`
	Address    string       `json:"address" gorm:"colum:address"` //gorm:"colum:address"指定列名
	UserDetail []UserDetail `json:"userDetail" gorm:"ForeignKey:Username;AssociationForeignKey:Username"`
}
